<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/powerFloat/js/mini/jquery-powerFloat-min.js" type="text/javascript"></script>

<script type="text/javascript">
	function sosuo(){
		var lpath =location.pathname;
		var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+pageNo);
		$("#soform").submit();
	}
	
	
	
	var fulldialog;
	function fullscreen(id,title){
		top.addTempTab("/enq/v_enquiry_item.do?so_enquiryid="+id);
	}
	
	function changestatrecallback(){
		refresh();
	}
	
	
	var exceldialog=null;
	function uploaddialog(enquiryid,title){
		var param ={id:enquiryid,title:title};
		exceldialog = art.dialog.uploadFile("上传excel",{callback:"uploadcallback",params:JSON.stringify(param),userpath:"admin",extensions:"xls,xlsx"});
	}
	
	function uploadcallback(response,params){
		exceldialog.close();
		art.dialog.post({
			url:"/enq/o_excel_update.do",
			data:{url:response.url,id:params.id,name:response.originalName},
			success:function(data){
				if(data.success){//更新成功
					art.dialog.tips("上传成功,转入分析");
					setTimeout(function(){
						//analysis(params.id,params.title);//分析excel
                        refresh();
					},100)
				}else{
					alert(data.msg);
				}			
			}
		},"更新地址");
	}
	
	/* 分析excel */
	function analysis(id,title){
        art.dialog({
            title:title,
            content: '1.普通分析:正常使用该方法进行分析</br>2.分组分析:应对一个excel里有多种表结构的情况,可以尝试此方式',
            button: [
                {
                    name: '<------------',
                    disabled: true
                },
                {
                    name: '普通分析',
                    callback: function () {
                        top.addTempTab("/enq/o_retry.do?id="+id+"&type=1");
                    },
                    focus: true
                },
                {
                    name: '分组分析',
                    callback: function () {
                        top.addTempTab("/enq/mulity_retry.do?id="+id+"&type=1");
                    }
                },
                {
                    name: '------------>',
                    disabled: true
                }
            ]
        });

	}
	

	
	/* 审核通过 */
// 	改变状态的提示页面
	function changeState(enquiryid ,prostate){
		art.dialog.load("请做出选择","/enq/v_prostate_change.do",{enquiryid:enquiryid,prostate:prostate});
	}

    $(function(){

        $('#showtip').tooltip({
            position: 'right',
            content: '<span style="color:#fff">This is the tooltip message.</span>',
            onShow: function(){
                $(this).tooltip('tip').css({
                    backgroundColor: '#666',
                    borderColor: '#666'
                });
            }
        });



        $("#startdate").datebox({
            formatter:function(date){
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                var d = date.getDate();
                return y+'-'+m+'-'+d;
            },
            onSelect:function(dateselect){
                //enddate清空
                $('#enddate').datebox('setValue', '');
                $("#enddate").datebox("calendar").calendar({
                    validator: function(date){
                        return dateselect <= date;
                    }
                });
            }
        });

        $("#enddate").datebox({
            formatter:function(date){
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                var d = date.getDate();
                return y+'-'+m+'-'+d;
            }
        })



        $("#startdate2").datebox({
            formatter:function(date){
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                var d = date.getDate();
                return y+'-'+m+'-'+d;
            },
            onSelect:function(dateselect){
                //enddate清空
                $('#enddate2').datebox('setValue', '');
                $("#enddate2").datebox("calendar").calendar({
                    validator: function(date){
                        return dateselect <= date;
                    }
                });
            }
        })

        $(".trigger4").powerFloat({
            targetMode: "ajax",
            position: "1-4"
        });
    })
</script>
</head>

<body>
	<div class="panel panel-default panel-content" style="overflow-y:auto;">
		<div class="panel-heading">
		<form  id="soform" method="post"  >
		<input type="hidden"  value="${EnqEnquiryQtypeEnum.ENQ_TYPE_CAIGOU.index}"  name="so_enq_or"   />
		<table >
			<tr>

                <td >
                    发布时间范围:
                    <input  name="so_pub_startdate" id="startdate"   value="${so_pub_startdate!}"  style="width:90px;"  > -
                    <input  name="so_pub_enddate"   id="enddate"     value="${so_pub_enddate!}"    style="width:90px;"  >
                </td>

                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                </td>

                <td >
                    截止时间范围:
                    <input  name="so_dead_startdate" id="startdate2"  value="${so_dead_startdate!}"  style="width:90px;"  /> -
                    <input  name="so_dead_enddate" id="enddate2"  value="${so_dead_enddate!}"  style="width:90px;"  />
                </td>
                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                </td>
				<td class="w110 ">
					<select class="form-control"  id="so_project_stat" name="so_project_stat"  >
						<option   value="-1"  >项目状态</option>
						[#list allstats?keys as key ]
							<option value="${key}"  [#if so_project_stat?? && so_project_stat==key ] selected="selected"  [/#if]  >${allstats[key]}</option>
						[/#list]
					</select>
				</td>
				<td class="w110 ">
					<select class="form-control"  id="so_enq_stat" name="so_enq_stat"  >
						<option   value="-1"  >询价状态</option>
						[#list allEnqStat?keys as key ]
							<option value="${key}"  [#if so_enq_stat?? && so_enq_stat==key ] selected="selected"  [/#if]    >${allEnqStat[key]}</option>
						[/#list]
					</select>
				</td>
				
				<td>
					<div class="input-group">
						<input type="text" class="form-control" style="width: 120px;" name="so_project_info"  value='${so_project_info!}' placeholder="项目名,询价名,公司名">
						<span class="input-group-btn">
							<button class="btn btn-default" type="button" onclick="sosuo()">多条件搜索</button>
						</span>
					</div>
				</td>
			</tr>
		</table>
		</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th>#</th>
					<th>项目名称</th>
					<th>询价名称</th>
					<th>发布商家</th>
					<th>联系信息</th>
                    <th>发布/截止</th>
					<th>项目状态</th>
                    <th>是否公开</th>
                    <th>审核状态</th>
					<th>excel</th>
					<th>操作</th>
				</tr>
			</thead>
			[#list pagination.list as enquiry ]
			<tr>
				<td>${pagination.pageSize * (pagination.pageNo-1)+enquiry_index+1}</td>
				<td style="word-wrap:break-word; white-space:normal; word-break:break-all; max-width: 300px;" >${enquiry.enqProject.projectName!}</div></td>
				<td style="word-wrap:break-word; white-space:normal; word-break:break-all; max-width: 200px;" >${enquiry.enquiryName!}</td>
				<td><a class="trigger4"   rel="/enq/compnay/godname.do?companyid=${enquiry.customerId}" >${(enquiry.companyName)!}</a></td>
				<td>${enquiry.contacts!}</br>[#if enquiry.phone?? ]${enquiry.phone}[#else]${enquiry.email!}[/#if]</td>
                <td>
					[#if  enquiry.pubdate??  ]${enquiry.pubdate?string("yyyy-MM-dd")!''}[/#if]</br>
					[#if enquiry.deadline?? ]${enquiry.deadline?string("yyyy-MM-dd")!''}[/#if]
                </td>
				<td>[#if enquiry.enqProject?? && enquiry.enqProject.state??]${allstats[enquiry.enqProject.state?string]!}[/#if]</td>
				<td>[#if enquiry.pubtype==1]公开[#else]不公开[/#if]</td>
				<td>

					[#if enquiry.state == 3]
						<a href="javascript:art.dialog.alert('退回原因：${enquiry.backreason!}');" title="退回原因" >${allEnqStat[enquiry.state?string]}</a>
					[#else]
						${allEnqStat[enquiry.state?string]}
					[/#if]
				</td>
				<td style="max-width: 130px;" >
				    [#if enquiry.excelpath?? && enquiry.excelpath!="" ]
					<a target="_blank" href="${enquiry.excelpath}">有<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span></a> 
					<a target="_blank" href="/enquiry/v_review.do?path=${enquiry.excelpath}">预览</a>
                        <button type="button" class="btn btn-xs btn-info" onclick="uploaddialog(${enquiry.id!},'${enquiry.enquiryName!}')">重传</button>
						[#if enquiry.itemscount != 0 ]
                        	<button type="button"   class="btn btn-xs btn-success" onclick="analysis(${enquiry.id!},'${enquiry.enquiryName!}')">分析</button>
						[#else]
                            <button type="button" title="未分析"   class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.enquiryName!}')">分析</button>
						[/#if]
					[#else]
						无
                        <button type="button" class="btn btn-xs btn-info" onclick="uploaddialog(${enquiry.id!},'${enquiry.title!}')">上传</button>
					[/#if]
				</td>
				
				<td style="max-width: 150px;">
					<button type="button" class="btn btn-xs btn-info" onclick="fullscreen(${enquiry.id!},'${enquiry.title!}')">详情</button>
					[#if enquiry.state == EnqEnquiryEnum.ENQ_STAY.index || enquiry.state == EnqEnquiryEnum.ENQ_RETRY.index ]
						[#if !(enquiry.hasQuoteAnalysis?? && enquiry.hasQuoteAnalysis > 0 ) ]
                        <button type="button" class="btn  btn-xs   btn-default" onclick="changeState(${enquiry.id},${EnqEnquiryEnum.ENQ_BACK.index})">退回</button>
						[/#if]
						[#if enquiry.itemscount != 0 ]
							<button type="button" class="btn  btn-xs  btn-success" onclick="changeState(${enquiry.id},${EnqEnquiryEnum.ENQ_POSTED.index})">通过</button>
						[/#if]
					[#elseif enquiry.state == EnqEnquiryEnum.ENQ_POSTED.index ]
						[#if !(enquiry.hasQuoteAnalysis?? && enquiry.hasQuoteAnalysis > 0 ) ]
							<button type="button" class="btn   btn-xs  btn-default" onclick="changeState(${enquiry.id},${EnqEnquiryEnum.ENQ_BACK.index})">退回</button>
						[/#if]
					[/#if ]

					[#if enquiry.hasQuoteAnalysis?? && enquiry.hasQuoteAnalysis > 0]
						<button type="button" class="btn   btn-xs  btn-default" onclick="location.href='/enq/v_quote_list.do?so_enq_id=${enquiry.id}';return false;">报价</button>
					[/#if]
				 </td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
</body>
</html>